package cn.jinjimi.app.modules.adv;

import com.google.gson.annotations.SerializedName;
import cn.jinjimi.base.util.GsonUtils;
import cn.jinjimi.app.entity.AppConfig.AppModule;
import cn.jinjimi.app.managers.ConfigManager;
import cn.jinjimi.app.modules.IModule;

/**
 * Created by Roy
 * Date: 16/8/19
 */
public class Adv implements IModule<Adv.Config> {

    private static volatile Adv mInstance = null;
    private Config mConfig;

    public static Adv getInstance() {
        if (mInstance == null) {
            synchronized (Adv.class) {
                if (mInstance == null) {
                    mInstance = new Adv();
                }
            }
        }
        return mInstance;
    }

    @Override
    public Config getConfig() {
        if (mConfig == null) {
            String data = ConfigManager.getInstance().getConfig(AppModule.ModuleAdv);
            mConfig = GsonUtils.fromJson(data, Config.class);
        }
        return mConfig;
    }

    public Config createConfig() {
        String data = ConfigManager.getInstance().getConfig(AppModule.ModuleAdv);
        mConfig = GsonUtils.fromJson(data, Config.class);
        return mConfig;
    }

    public static class Config {

        @SerializedName("INDEX")
        public String INDEX;

        @SerializedName("START")
        public String START;

    }
}
